define(['can/util/fixture', 'app/model/Comments'], function(fixture, comments) {
    'use strict';

    describe('comments model', function() {
        
        it('will load comments from external model', function() {
            
            var flag, value,
            passFlag = function(v) {
                value = v;
                flag = true;
            };
            
            fixture('GET /comments.json', 'fixture/comments.json');
            fixture('GET /comments/xyz.json', 'fixture/comment.json');

            runs(function() {
                flag = false;
                comments.findAll({}, passFlag);
            });

            waitsFor(function() {
                return flag;
            }, 'Model should return all comments', 750);

            runs(function() {
                expect(value[0].id).toBe('xyz');
            });
            
            runs(function() {
                flag = false;
                comments.findOne({id:'xyz'}, passFlag);
            });

            waitsFor(function() {
                return flag;
            }, 'Model should return a single comment', 750);

            runs(function() {
                expect(value.id).toBe('xyz');
            });

        });
    });

});
